<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input type="hidden" id="id" name="id">

                        <!--    b赛场裁判-->
                        <div id="a">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判一改分：</label>
                                <div class="col-sm-8">
                                    <p>婴幼儿保育技能实操</p>
                                    <input name="scoinga1" oninput="changesInput('婴幼儿保育技能实操',event.target.value)"   class="form-control" type="text" id="scoinga1">
<!--                                    <p>幼儿园保教活动课件制作</p>-->
<!--                                    <input name="scoingb1s"  oninput="changesInput('幼儿园保教活动课件制作',event.target.value)"  class="form-control" type="text" id="scoingb1s">-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判二改分：</label>
                                <div class="col-sm-8">
                                    <p>婴幼儿保育技能实操</p>
                                    <input name="scoinga2" oninput="changesInput('婴幼儿保育技能实操',event.target.value)" class="form-control" type="text" id="scoinga2">
<!--                                    <p>幼儿园保教活动课件制作</p>-->
<!--                                    <input name="scoingb2s" oninput="changesInput('幼儿园保教活动课件制作',event.target.value)" class="form-control" type="text" id="scoingb2s">-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判三改分：</label>
                                <div class="col-sm-8">
                                    <p>婴幼儿保育技能实操</p>
                                    <input name="scoinga3" oninput="changesInput('婴幼儿保育技能实操',event.target.value)" class="form-control" type="text" id="scoinga3">
                                </div>
                            </div>
                        </div>
                        <!--    a赛场裁判-->
                        <div id="b">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判一改分：</label>
                                <div class="col-sm-8">
                                    <p>案例分析</p>
                                    <input name="scoingb1" oninput="changesInput('案例分析',event.target.value)" class="form-control" type="text" id="scoingb1">
<!--                                    <p>幼儿行为观察</p>-->
<!--                                    <input name="scoinga1s" oninput="changesInput('幼儿行为观察',event.target.value)" class="form-control" type="text" id="scoinga1s">-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判二改分：</label>
                                <div class="col-sm-8">
                                    <p>案例分析</p>
                                    <input name="scoingb2" oninput="changesInput('案例分析',event.target.value)" class="form-control" type="text" id="scoingb2">
<!--                                    <p>幼儿行为观察</p>-->
<!--                                    <input name="scoinga2s" oninput="changesInput('幼儿行为观察',event.target.value)" class="form-control" type="text" id="scoinga2s">-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判三改分：</label>
                                <div class="col-sm-8">
                                    <p>案例分析</p>
                                    <input name="scoingb3" oninput="changesInput('案例分析',event.target.value)" class="form-control" type="text" id="scoingb3">
<!--                                    <p>幼儿行为观察</p>-->
<!--                                    <input name="scoinga3s" oninput="changesInput('幼儿行为观察',event.target.value)" class="form-control" type="text" id="scoinga3s">-->
                                </div>
                            </div>

                        </div>

                        <!--    c赛场裁判-->
                        <div id="c">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判一改分：</label>
                                <div class="col-sm-8">
                                    <p>婴幼儿早期学习支持</p>
                                    <input name="scoingc1" oninput="changesInput('婴幼儿早期学习支持',event.target.value)" class="form-control" type="text" id="scoingc1">
<!--                                    <p>集体教学活动设计</p>-->
<!--                                    <input name="scoingc1s" oninput="changesInput('集体教学活动设计',event.target.value)" class="form-control" type="text" id="scoingc1s">-->
<!--                                    <p>说课</p>-->
<!--                                    <input name="scoingc1ls" oninput="changesInput('说课',event.target.value)" class="form-control" type="text" id="scoingc1ls">-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判二改分：</label>
                                <div class="col-sm-8">
                                    <p>婴幼儿早期学习支持</p>
                                    <input name="scoingc2" oninput="changesInput('婴幼儿早期学习支持',event.target.value)" class="form-control" type="text" id="scoingc2">
<!--                                    <p>集体教学活动设计</p>-->
<!--                                    <input name="scoingc2s" oninput="changesInput('集体教学活动设计',event.target.value)" class="form-control" type="text" id="scoingc2s">-->
<!--                                    <p>说课</p>-->
<!--                                    <input name="scoingc2ls" oninput="changesInput('说课',event.target.value)" class="form-control" type="text" id="scoingc2ls">-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-3 control-label">裁判三改分：</label>
                                <div class="col-sm-8">
                                    <p>婴幼儿早期学习支持</p>
                                    <input name="scoingc3" oninput="changesInput('婴幼儿早期学习支持',event.target.value)" class="form-control" type="text" id="scoingc3">
<!--                                    <p>集体教学活动设计</p>-->
<!--                                    <input name="scoingc3s" oninput="changesInput('集体教学活动设计',event.target.value)" class="form-control" type="text" id="scoingc3s">-->
<!--                                    <p>说课</p>-->
<!--                                    <input name="scoingc3ls" oninput="changesInput('说课',event.target.value)" class="form-control" type="text" id="scoingc3ls">-->
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="button" onclick="update()" class="btn btn-primary">提交</button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<!--<script src="//s.xlongwei.com/res/js/My97DatePicker/WdatePicker.js"></script>-->
<script>
    let obj = JSON.parse(sessionStorage.getItem("obj"));
    let listA = ["#scoinga1","#scoinga2","#scoinga3"]
    let listB = ["#scoingb1","#scoingb2","#scoingb3",]
    let listC = ["#scoingc1","#scoingc2","#scoingc3"]
    let flag = null
    function changesInput (value,e) {
        if(value === '案例分析') {
            if(e.trim() >15) {
                flag = false
                layer.msg('分数不能超过15');
                return
            }
            flag = true
        }else if(value === '婴幼儿保育技能实操'){
            if(e.trim() >40) {
                flag = false
                layer.msg('分数不能超过40');
                return
            }
            flag = true
        }else if (value === '婴幼儿早期学习支持') {
            if(e.trim() >30) {
                flag = false
                layer.msg('分数不能超过30');
                return
            }
            flag = true
        }

    }


    function listData (value) {
        for (let i = 0; i < value.length; i++) {
            if($(value[i])?.val() =="") {
                layer.msg('分数不能为空');
                return flag = false
            }else {
                 flag = true

            }
        }
        for (let i = 0; i < value.length ; i++) {
            if(!flag) return
            console.log($(value[i]).prev())
            changesInput($(value[i]).prev()[0].innerText,$(value[i]).val())
        }
    }


    if( obj ){
        if( obj.type == 1 ){
            $("#c").remove();
            $("#b").remove();

        }
        if( obj.type == 2 ){
            $("#a").remove();
            $("#c").remove();
        }
        if( obj.type == 3 ){
            $("#a").remove();
            $("#b").remove();
        }
        $("#id").val(obj.id)
        //B
        $("#scoinga1").val(obj.scoinga1)
        $("#scoinga2").val(obj.scoinga2)
        // $("#scoinga2s").val(obj.scoinga2s)
        $("#scoinga3").val(obj.scoinga3)
        // $("#scoinga3s").val(obj.scoinga3s)
        // $("#scoinga4").val(obj.scoinga4)
        // $("#scoinga4s").val(obj.scoinga4s)
        // $("#scoinga5").val(obj.scoinga5)
        // $("#scoinga5s").val(obj.scoinga5s)

        //A
        $("#scoingb1").val(obj.scoingb1)
        // $("#scoingb1s").val(obj.scoingb1s)
        $("#scoingb2").val(obj.scoingb2)
        // $("#scoingb2s").val(obj.scoingb2s)
        $("#scoingb3").val(obj.scoingb3)
        // $("#scoingb3s").val(obj.scoingb3s)
        // $("#scoingb4").val(obj.scoingb4)
        // $("#scoingb4s").val(obj.scoingb4s)
        // $("#scoingb5").val(obj.scoingb5)
        // $("#scoingb5s").val(obj.scoingb5s)

        //C
        $("#scoingc1").val(obj.scoingc1)
        // $("#scoingc1s").val(obj.scoingc1s)
        $("#scoingc2").val(obj.scoingc2)
        // $("#scoingc2s").val(obj.scoingc2s)
        $("#scoingc3").val(obj.scoingc3)
        // $("#scoingc3s").val(obj.scoingc3s)
        // $("#scoingc4").val(obj.scoingc4)
        // $("#scoingc4s").val(obj.scoingc4s)
        // $("#scoingc5").val(obj.scoingc5)
        // $("#scoingc5s").val(obj.scoingc5s)
        // $("#scoingc1ls").val(obj.scoingc1ls)
        // $("#scoingc2ls").val(obj.scoingc2ls)
        // $("#scoingc3ls").val(obj.scoingc3ls)
        // $("#scoingc4ls").val(obj.scoingc4ls)
        // $("#scoingc5ls").val(obj.scoingc5ls)

    }
    // $('#signupForm').serialize()
    let ob = { scoinga1:'52345235',scoinga1s:'253532532' };


    function update() {
        if( !obj.id ){
            layer.msg('该考生暂未参加考试');
            return false;
        }
        // a
        if( obj.type == 1 ){
            listData(listA)
        }
        // b
        if( obj.type == 2 ){
            listData(listB)
        }
        //c
        if( obj.type == 3 ){
            listData(listC)
        }
        console.log(flag)
        if(flag){
            $.ajax({
                cache : true,
                type : "get",
                url : "/jzweb/stuSignUpScoring/updateScoingABC",
                data : $('#signupForm').serialize(),// 你的formid
                async : false,
                error : function(request) {
                    parent.layer.alert("Connection error");
                },
                success : function(data) {
                    if (data.code == 0) {
                        parent.layer.msg("操作成功");
                        parent.reLoad();
                        var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                        parent.layer.close(index);

                    } else {
                        parent.layer.alert(data.msg)
                    }

                }
            });
        }


    }

</script>
</body>
</html>
